import { reqGetSearchInfo } from "@/api";
// search模块的小仓库
const state = {
    // search仓库初始状态
    searchList: {}
};
const mutations = {
    GETSEARCHLIST(state, searchList) {
        state.searchList = searchList
    }
};
const actions = {
    // 获取search模块数据
    async getSearchList({ commit }, params = {}) {
        let result = await reqGetSearchInfo(params)
        if (result.code == 200) {
            commit("GETSEARCHLIST", result.data)
        }
    }
};
// getters是对state的数据进行处理 以便后续使用
const getters = {
    goodsList(state) {
        // 如果没网是返回空数组 不能是undefined
        return state.searchList.goodsList || []
    },
    trademarkList(state) {
        return state.searchList.trademarkList
    },
    attrsList(state) {
        return state.searchList.attrsList
    }
};

export default {
    state,
    mutations,
    actions,
    getters,
}